'use strict';

var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault');
Object.defineProperty(exports, '__esModule', {
  value: true,
});
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require('@babel/runtime/helpers/objectSpread2'));
var _objectWithoutProperties2 = _interopRequireDefault(
  require('@babel/runtime/helpers/objectWithoutProperties'),
);
var _react = _interopRequireDefault(require('react'));
var _antd = require('antd');
var _utils = require('./utils');
var _createField = _interopRequireDefault(require('../../createField'));
var _FormContext = require('../../contexts/FormContext');
var _FieldContext = require('../../contexts/FieldContext');
var _excluded = ['maxLength', 'valueType'];
var Input = function Input(_ref) {
  var _ref$maxLength = _ref.maxLength,
    maxLength = _ref$maxLength === void 0 ? 30 : _ref$maxLength,
    valueType = _ref.valueType,
    props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  var form = (0, _FormContext.useFormContext)();
  var _useFieldContext = (0, _FieldContext.useFieldContext)(),
    label = _useFieldContext.label;
  var extraProps = (0, _utils.getExtraProps)(
    (0, _objectSpread2.default)(
      {
        valueType: valueType,
      },
      props,
    ),
    form,
  );
  return /*#__PURE__*/ _react.default.createElement(
    _antd.Input,
    (0, _objectSpread2.default)(
      (0, _objectSpread2.default)(
        {
          placeholder: '\u8BF7\u8F93\u5165'.concat(label),
          maxLength: maxLength,
        },
        extraProps,
      ),
      props,
    ),
  );
};
var _default = (0, _createField.default)(Input, {
  defaultDetailType: 'text',
  getFormItemPropsFromProps: function getFormItemPropsFromProps(props, form) {
    return {
      rules: (0, _utils.getRulesFromProps)(props, form),
    };
  },
});
exports.default = _default;
